﻿<template>
    <div class="page view-image-page">
        <div class="navbar">
            <div class="navbar-bg"></div>
            <div class="navbar-inner navbar-inner-centered-title">
                <div class="left">
                    <a class="link back">
                        <i class="icon icon-back color-primary"></i>
                    </a>
                </div>
                <div class="title text-color-primary">检查图像</div>
            </div>
        </div>
        <div class="page-content" id="image-page-content">
            <iframe src="../mobile/index" sandbox="allow-forms allow-scripts allow-top-navigation allow-same-origin">
            </iframe>
        </div>
    </div>
</template>
<script>
    export default (props, { $, $on, $f7, $h, $f7router, $theme, $update, $store }) => {
        let examId = '';
        $on('pageInit', (e, page) => {
            $f7.on("LookPicture", () => {
                if (examId !== $store.getters.examId.value) {
                    examId = $store.getters.examId.value;
                    fetch(`/api/exam/get-dicom-client-url`, {
                        method: 'GET',
                        headers: { 'Content-Type': 'application/json' }
                    }).then((res) => {
                        res.json().then((result) => {
                            if (result.success && result.data) {
                                let url = result.data;
                                if (result.data.includes('?')) {
                                    url += `&examIds=${examId}`;
                                } else {
                                    url += `?examIds=${examId}`;
                                }
                                let $iframe = $(".view-image-page #image-iframe");
                                $iframe[0].contentWindow.location = url;
                            }
                        });
                    })
                }
            })
            $("#close-iamge-popup").on('click', () => {
                $('.image-popup').hide();
                $('.popup-backdrop').hide();
            });
        })
        return $render;
    };
</script>
